import React, { useEffect, useState } from 'react'
import '@/index.css'
import { withRouter } from 'react-router'
import { useLocation } from 'react-router-dom'

const Header = ({ history }) => {
    const { pathname } = useLocation()
    const [showBack, setShowBack] = useState(true)
    useEffect(() => {
        console.log(pathname);
        if (pathname === '/' || pathname === '/me') {
            setShowBack(false)
        } else {
            setShowBack(true)
        }
    }, [pathname])

    return <div className="h-wrapper">
        <div className="title-header">
            <div className="th-name">左记点单系统</div>
            {showBack ? <img className="back-icon" onClick={() => history.goBack()} src={require('@/icons/back.svg').default} alt="back" />
                : null}
        </div>
    </div>
}

export default withRouter(Header)